package com.magenta.maxoptra.gis;

import com.magenta.maxoptra.gis.commons.Pair;
import com.magenta.maxoptra.gis.commons.Triple;

import java.util.Date;

/*
* Project: MaxOptRA v1.1
* User: Ivan Usalko
* Date: 08.04.2009 17:55:37
*
* Copyright (c) 1999-2009 Magenta Corporation Ltd. All Rights Reserved.
* Magenta Technology proprietary and confidential.
* Use is subject to license terms.
*/
/**
 * Interface RoutesCache ...<br>
 * Mapped request parameters to provider response (route info).
 */
public interface RoutesCache {

    void put(GeographicCoordinates from, GeographicCoordinates to, Triple<Double, Long, Long> route);

    /**
     * Place route info into cache.
     * @param latFrom in degree.
     * @param lonFrom in degree.
     * @param latTo in degree.
     * @param lonTo in degree.
     * @param route info.
     */
    void put(int latFrom, int lonFrom, int latTo, int lonTo, Triple<Double, Long, Long> route);

    /**
     * Place route with actuality info into cache.
     * @param latFrom in degree.
     * @param lonFrom in degree.
     * @param latTo in degree.
     * @param lonTo in degree.
     * @param route info.
     */
    void putRTI(int latFrom, int lonFrom, int latTo, int lonTo, Triple<Double, Long, Date> route);

    Pair<Double, Long> get(GeographicCoordinates from, GeographicCoordinates to);

    /**
     * Return Triple&lt;distance, duration, last update time&gt;
     */
    Triple<Double, Long, Long> getWithAge(GeographicCoordinates from, GeographicCoordinates to);

    /**
     * Search route in persistent state,
     * then update in memory cache if found it.
     * @param cid provider class id.
     * @param from location.
     * @param to location.
     * @return null if not found.
     */
    @Deprecated
    Triple<Double, Long, Long> update(Long cid, GeographicCoordinates from, GeographicCoordinates to);

    /**
     * Search route with actuality info in persistent state,
     * then update in memory cache if found it. Route info with actuality date.
     * @param cid provider class id.
     * @param from location.
     * @param to location.
     * @return null if not found.
     */
    @Deprecated
    Triple<Double, Long, Date> updateRTI(Long cid, GeographicCoordinates from, GeographicCoordinates to);

    void clear();

    String stat();

    Object getKey(int lat1, int lon1, int lat2, int lon2);

    void remove(GeographicCoordinates from, GeographicCoordinates to);

    /**
     * Size of memory cache.
     * @return number of records in memory cache.
     */
	int size();
}
